#include "TextScreen.h"
TextScreen::TextScreen(int w, int h)
{
    width = w;
    height = h;
    screen = new char[80*80];
    clear();
}
TextScreen::~TextScreen()
{
    delete []screen;
}
void TextScreen::clear()
{
    for(int  i = 0; i<height; i++)
    {
        int j = 0;
        for(j  = 0; j<width; j++)
        {
            screen[i*80+j] = ' ';
        }
        screen[i*80-1] = '\n';
        //screen[i*80-2] = '\r';
    }          
    screen[width*height -1] = '\0';    
}
void TextScreen::draw(int x, int y, char * str)
{
    int len = strlen(str);
    for(int i = 0; i<len; i++)
         screen[y*80+x+i] = str[i];
    
}
void TextScreen::update()
{
    system("clear");
      for(int i = 0; i<width*height-1; i++)
           std::cout<<(char)screen[i];
      
}